package org.agile2soft.nexoma.tapestry.components;

import org.apache.tapestry5.annotations.*;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.RenderSupport;

/**
 * Layout component for pages of application geloa2.
 */
@IncludeStylesheet("context:resources/styles/layout.css")
@IncludeJavaScriptLibrary({"context:resources/js/layout.js"
                          ,"context:resources/js/scriptaculous-corners.js"
})
public class ApplicationLayout
{
    /** The page title, for the <title> element and the <h1> element. */
    @Property
    @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
    @SuppressWarnings("unused")
    private String title;

    @Inject
    private RenderSupport _support;

    @AfterRender
    void afterRender() {
        _support.addInit("layoutmanager","container");
    }

    @Parameter
    private Block header;

    @Inject
    private Block defaultHeader;

    public Block getHeader() {
        return ( null!=header ) ? header : defaultHeader;
    }

    @Parameter
    private Block leftMenu;

    @Inject
    private Block defaultLeftMenu;

    public Block getLeftMenu() {
        return ( null!=leftMenu) ? leftMenu: defaultLeftMenu;
    }

    @Parameter
    private Block rightMenu;

    @Inject
    private Block defaultRightMenu;

    public Block getRightMenu() {
        return ( null!=rightMenu) ? rightMenu: defaultRightMenu;
    }


    @Inject
    private ComponentResources componentResources;

    public String getCurrentPageName() {
        return componentResources.getPageName();
    }



}
